Skip to content

feat: Increase specificity of WebSocket.readyState #2109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tpict
Copy link

@tpict tpict commented Aug 6, 2025

The MDN docs say this is strictly one of the four values that we already have references to as WebSocket.CONNECTING etc.

Copy link
Contributor

github-actions bot commented Aug 6, 2025

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

@tpict
Copy link
Author

tpict commented Aug 6, 2025

cc @jbzd

@tpict
Copy link
Author

tpict commented Aug 6, 2025

@microsoft-github-policy-service agree company="EverCommerce"

@@ -36690,7 +36690,7 @@ interface WebSocket extends EventTarget {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
*/
readonly readyState: number;
readonly readyState: typeof WebSocket.CONNECTING | typeof WebSocket.OPEN | typeof WebSocket.CLOSING | typeof WebSocket.CLOSED;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
readonly readyState: typeof WebSocket.CONNECTING | typeof WebSocket.OPEN | typeof WebSocket.CLOSING | typeof WebSocket.CLOSED;
readonly readyState: 0 | 1 | 2 | 3;

This is more performant and compiles to the same output. Using the WebSocket.CONNECTING | ... approach adds unnecessary complexity without functional benefit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants